* Table A18: Summary Statistics, Baseline and Life Cycle Samples
clear
use "${data_dir}DavisMazumderData.dta"

keep if age_firstSurvey<=18
drop if miss0 | miss1


merge 1:1 id_son id_daughter CASEID using ${data_dir}nobs.dta


keep if obs>=10 & obs<.



gen dad_present = dad_age_b<. 
gen mom_present = mom_age_b<. 
gen spouse_present = spouse_age<.

gen keep =  !((mom_outOfRange==1 & linkMom==1 & !(dad_outOfRange==0 & linkDad==1)) | (dad_outOfRange==1 & linkDad==1 & !(mom_outOfRange==0 & linkMom==1)) | (linkMom==0 & linkDad==0) ) 
keep if keep==1


mat sumstat_w = ., ., ., ., ., .


foreach var of varlist linkDad linkMom linkBoth faminc0 lfaminc0 dad_present dad_age_b mom_present mom_age_b kid_age_parent faminc1 lfaminc1 kid_age spouse_present spouse_age white black nsib unemp_parent unemp_kid {

  
 su `var' [w=weight] if surv79==0 & women==1
 gen float n66 = round(r(N),.001)
 gen float mn66 = round(r(mean),.001)
 gen float sd66 = round(r(sd),.001)
 su n66
 local n66 = r(mean)
 su mn66
 local m66 = r(mean)
 su sd66
 local s66 = r(mean)
 
 su `var' [w=weight] if surv79==1 & women==1
 gen float n79 = round(r(N),.001)
 gen float mn79 = round(r(mean),.001)
 gen float sd79 = round(r(sd),.001)
 su n79
 local n79 = r(mean)
 su mn79
 local m79 = r(mean)
 su sd79
 local s79 = r(mean)
 
 
 mat sumstat_w = sumstat_w \ (`n66', `m66', `s66', `n79', `m79', `s79')
 drop n66 mn66 sd66 n79 mn79 sd79
 

 
 
}

* Note that left panel is just a duplication of part of Table A5
clear
svmat sumstat_w
outsheet using ${results_dir}tableA18.csv, comma names replace 

exit
